﻿using System.ComponentModel.Composition;
using System.Diagnostics;
using COFE.Core;
using COFE.Core.EntryType;
using COFE.Core.Plugin;
using COFE.Data.Lister;
using COFE.Data.Profile;
using COFE.Core.Lister;
using COFE.Core.Utils;
using COFE.Core.Actions;
using COFE.Core.Logger;
using System.Collections.Generic;
using COFE.Data.Utils;
using COFE.Data.Filter;
using COFE.Core.Filter;
using System;

namespace COFE.Data.Plugin
{
    [Export(typeof(IPlugin))]
    public partial class COFEDBPlugin : COFEPluginBase,
        ICOFEActionPlugin, ICOFEDBPlugin
    {
        #region Constructor

        public COFEDBPlugin()
            : base(COFEPluginBase.Priority_COFEDB)
        {

            PropertyDictionary = new DBPropertyDictionary();
            VolumeRegistrar = new DBVolumeRegistrar();
            PathParser = new DBPathParser();
            EntryConstructor = new DBEntryConstructor();
            EntryListRegistrar = new DBEntryListRegistrar();
            UserProfileManager = new DBUserProfileManager();
            EntryTypeDictionary = new DBEntryTypeDictionary(new DBEntryIconExtractor(), new EntryTypeFilterGenerator());

            _directoryListerFactories.AddRange(new IFactory<IDirectoryLister>[]
            {
                new COFE.Data.DBLink.DBLinkFactory("DBLINK")
            });
            registerProperties<DatabaseProperties>();

            FileSystemEventLogger = new DBFileSystemEventLogger();
            WorkScheduler = new DBWorkScheduler();
            WorkEventLogger = new DBWorkEventLogger();

            _entryPropertyProviders.Add(
                new DBLastListTimePropertyProvider()
             );

            _entryFilters.Add(
                typeof(DBExpireEntryFilter)                
            );

            EntryFilterExpressions = new List<IFilterExpression<IEntryFilter>>()
                {
                    new RootEntryFilterExpression(),
                    new FileTypeEntryFilterExpression(),
                    new FileNameEntryFilterExpression(),
                    new GuidEntryFilterExpression(),
                    new OrEntryFilterExpression(),
                    new PropertyEntryFilterExpression(),
                    new DBExpireEntryFilterExpression()
                };
            OptionFilterExpressions = new List<IFilterExpression<IOptionFilter>>()
                {
                    new SortResultOptionFilterExpression(),
                    new PaginateOptionFilterExpression()
                };



        }

        #endregion

        #region Methods




        #endregion

        #region Data


        #endregion

        #region Public Properties

        public List<IFilterExpression<IEntryFilter>> EntryFilterExpressions { get; private set; }
        public List<IFilterExpression<IOptionFilter>> OptionFilterExpressions { get; private set; }
        public IWorkScheduler WorkScheduler { get; set; }
        public IEventLogger<WorkEventArgs> WorkEventLogger { get; set; }

        #endregion








    }
}
